﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using ReflectionStudio.Core.Events;
namespace WPFExcelReport
{ 
    public class EK03HISTORYData : BaseFunction
    {


        public EK03HISTORYData()
            : base()
        {

        }

        public EK03HISTORYData(Dictionary<string, object> DicGlobalPara)
            : base(DicGlobalPara)
        {
        }


        public DataSet BuildData()
        {
            DataSet setReturn = new DataSet();
            DataSet dsResult = new DataSet();
            try
            {
                orlReadCommand = OracleDB.CreateCommand();
                orlReadCommand = OracleDB.CreateCommand();
                orlReadCommand.CommandText = "SELECT * FROM PURCHASE_REPORT ";

                dsResult = Connect2Proxy(orlReadCommand);
                if (dsResult.Tables.Count > 0)
                {
                    dsResult.Tables[0].TableName = "Pur_Mat_List";

                    byte[] b;
                    string value;
                    string ColumnName = "";
                    foreach (DataRow dw in dsResult.Tables["Pur_Mat_List"].Rows)
                    {
                        ColumnName = "DES";
                        b = Encoding.GetEncoding("ISO-8859-1").GetBytes(dw[ColumnName].ToString().Trim());
                        value = Encoding.GetEncoding("gb2312").GetString(b);
                        dw[ColumnName] = value;
                        ColumnName = "COLOR";
                        b = Encoding.GetEncoding("ISO-8859-1").GetBytes(dw[ColumnName].ToString().Trim());
                        value = Encoding.GetEncoding("gb2312").GetString(b);
                        dw[ColumnName] = value;
                        ColumnName = "SUPPLIER";
                        b = Encoding.GetEncoding("ISO-8859-1").GetBytes(dw[ColumnName].ToString().Trim());
                        value = Encoding.GetEncoding("gb2312").GetString(b);
                        dw[ColumnName] = value;
                    }
                }
                setReturn.Merge(dsResult);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return setReturn;
        }
    }
}